<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:composite="http://java.sun.com/jsf/composite">

    <composite:interface>

        <composite:attribute name="idDisabled"/>
        <composite:attribute name="enabledDisabled"/>
        <composite:attribute name="nameDisabled"/>
        <composite:attribute name="descriptionDisabled"/>
        <composite:attribute name="localeDisabled"/>
        <composite:attribute name="themeDisabled"/>    
        <composite:attribute name="emailAddressDisabled"/>  

        <composite:attribute name="nameRequired"/>
        <composite:attribute name="localeRequired"/>
        <composite:attribute name="themeRequired"/>
        <composite:attribute name="emailAddressRequired"/>
        <composite:attribute name="passwordRequired"/>
        <composite:attribute name="passwordConfirmationRequired"/>

        <composite:attribute name="generatePasswordButtonRendered"/>
        <composite:attribute name="passwordRendered"/>
        <composite:attribute name="passwordConfirmationRendered"/>     

    </composite:interface>

    <h:panelGrid columns="3"
                 columnClasses="columnWidth48, columnWidth4, columnWidth48"
                 width="90%"
                 style="margin-left: auto; margin-right: auto">

        <h:panelGrid columns="1"
                     columnClasses="columnWidth100"
                     rowClasses="rowAlign"
                     width="100%">

            <p:outputLabel value="#{bundle.Name}" 
                           for="name"/>

            <p:inputText id="name"
                         style="width: 100%; margin-bottom: 2%"
                         value="#{userController.selected.name}"
                         tabindex="01"
                         disabled="#{cc.attrs.nameDisabled}"
                         required="#{cc.attrs.nameRequired}"/>

            <p:outputLabel value="#{bundle.Locale}"
                           for="locale"/>

            <p:selectOneMenu id="locale"
                             style="width: 100%; margin-bottom: 1.2%"
                             value="#{userController.locale}"
                             tabindex="03"
                             converter="localeConverter"
                             disabled="#{cc.attrs.localeDisabled}"
                             required="#{cc.attrs.localeRequired}">

                <f:selectItems value="#{localizationUtil.itemsAvailableSelectOne}"/>   

            </p:selectOneMenu>       

            <p:outputLabel value="#{bundle.EmailAddress}" 
                           for="emailAddress"/>

            <p:inputText id="emailAddress" 
                         style="width: 100%; margin-bottom: 2.4%"
                         value="#{userController.selected.emailAddress}"
                         tabindex="05"
                         disabled="#{cc.attrs.emailAddressDisabled}"
                         required="#{cc.attrs.emailAddressRequired}"/> 

            <p:outputLabel value="#{bundle.Password}"
                           rendered="#{cc.attrs.passwordRendered}"
                           for="password"/>

            <p:password id="password"
                        style="width: 100%"
                        value="#{userController.selected.password}"
                        tabindex="07"
                        redisplay="true"
                        match="passwordConfirmation"
                        label="#{bundle.Password}"
                        validatorMessage="#{bundle.PasswordsDontMatch}"
                        feedback="true"
                        promptLabel="#{bundle.PromptPassword}"
                        weakLabel="#{bundle.Weak}"
                        goodLabel="#{bundle.Good}"
                        strongLabel="#{bundle.Strong}"
                        required="#{cc.attrs.passwordRequired}"
                        rendered="#{cc.attrs.passwordRendered}"/>         

        </h:panelGrid>

        <p:spacer/>

        <h:panelGrid columns="1"
                     columnClasses="columnWidth100"
                     rowClasses="rowAlign"
                     width="100%">         

            <p:outputLabel value="#{bundle.Description}" 
                           for="description"/>

            <p:inputText id="description" 
                         style="width: 100%; margin-bottom: 2%"
                         value="#{userController.selected.description}"
                         tabindex="02"
                         disabled="#{cc.attrs.descriptionDisabled}"/> 

            <p:outputLabel value="#{bundle.Theme}"
                           for="theme"/>

            <p:selectOneMenu id="theme"
                             style="width: 100%; margin-bottom: 1.2%"
                             value="#{userController.selected.theme}"
                             tabindex="04"
                             disabled="#{cc.attrs.themeDisabled}"
                             required="#{cc.attrs.themeRequired}">

                <f:selectItems value="#{themeUtil.itemsAvailableSelectOne}"/>   

            </p:selectOneMenu>       

            <p:spacer/>  

            <p:commandButton id="generatePasswordButton"
                             style="width: 100%; margin-bottom: 1%"
                             value="#{bundle.GeneratePassword}"
                             tabindex="06"
                             onclick="PF('generatePasswordDialog').show()"
                             rendered="#{cc.attrs.generatePasswordButtonRendered}"/>       

            <p:outputLabel value="#{bundle.PasswordConfirmation}" 
                           rendered="#{cc.attrs.passwordConfirmationRendered}"
                           for="passwordConfirmation"/>

            <p:password id="passwordConfirmation"
                        style="width: 100%"
                        value="#{userController.selected.password}"
                        tabindex="08"
                        redisplay="true"
                        label="#{bundle.PasswordConfirmation}"
                        required="#{cc.attrs.passwordConfirmationRequired}"
                        rendered="#{cc.attrs.passwordConfirmationRendered}"/>       

        </h:panelGrid>       

    </h:panelGrid>

    <p:dialog header="#{bundle.AdditionalInfo}"
              widgetVar="additionalInfoDialog"
              resizable="false" 
              modal="true" 
              showEffect="fade"
              hideEffect="fade" 
              draggable="false"
              width="48%"
              style="margin-left: auto; margin-right: auto">

        <h:panelGrid columns="3"
                     columnClasses="columnWidth48, columnWidth4, columnWidth48"
                     width="90%"
                     style="margin-left: auto; margin-right: auto">

            <h:panelGrid columns="1"
                         columnClasses="columnWidth100"
                         rowClasses="rowAlign"
                         width="100%">

                <p:outputLabel value="#{bundle.Id}" 
                               for="id"/>

                <p:inputText id="id" 
                             style="width: 100%; margin-bottom: 2%"
                             value="#{userController.selected.id}"
                             disabled="true"/>         

                <p:outputLabel value="#{bundle.CreatedBy}" 
                               for="createdBy"/>

                <p:inputText id="createdBy" 
                             style="width: 100%; margin-bottom: 2%"
                             value="#{userController.selected.createdBy.name}"
                             disabled="true"/>

                <p:outputLabel value="#{bundle.UpdatedBy}" 
                               for="updatedBy"/>

                <p:inputText id="updatedBy"   
                             style="width: 100%; margin-bottom: 2%"
                             value="#{userController.selected.updatedBy.name}"
                             disabled="true"/> 

                <p:outputLabel value="#{bundle.LastPasswordChange}" 
                               for="lastPasswordChange"/>

                <p:inputText id="lastPasswordChange"
                             style="width: 100%"                
                             value="#{userController.selected.lastPasswordChange}"
                             disabled="true">

                    <f:convertDateTime 
                        locale="#{localizationUtil.selected}" 
                        type="both"
                        pattern="#{localizationUtil.dateTimeFormatMediumPattern}" 
                        timeZone="#{localizationUtil.defaultTimeZone}"/>

                </p:inputText>        

            </h:panelGrid>

            <p:spacer/>

            <h:panelGrid columns="1"
                         columnClasses="columnWidth100"
                         rowClasses="rowAlign"
                         width="100%">

                <p:outputLabel value="#{bundle.Enabled}" 
                               for="enabled"/>

                <p:selectBooleanCheckbox id="enabled"
                                         style="vertical-align: -22%; margin-bottom: 4%"
                                         value="#{userController.selected.enabled}"
                                         disabled="#{cc.attrs.enabledDisabled}"/>         

                <p:outputLabel value="#{bundle.Created}" 
                               for="created"/>

                <p:inputText id="created"
                             style="width: 100%; margin-bottom: 2%"
                             value="#{userController.selected.created}"
                             disabled="true">

                    <f:convertDateTime 
                        locale="#{localizationUtil.selected}" 
                        type="both"
                        pattern="#{localizationUtil.dateTimeFormatMediumPattern}" 
                        timeZone="#{localizationUtil.defaultTimeZone}"/>      

                </p:inputText>  

                <p:outputLabel value="#{bundle.Updated}" 
                               for="updated"/>

                <p:inputText id="updated"
                             style="width: 100%; margin-bottom: 2%"
                             value="#{userController.selected.updated}"
                             disabled="true">

                    <f:convertDateTime 
                        locale="#{localizationUtil.selected}" 
                        type="both"
                        pattern="#{localizationUtil.dateTimeFormatMediumPattern}" 
                        timeZone="#{localizationUtil.defaultTimeZone}"/>

                </p:inputText>

                <p:outputLabel value="#{bundle.LastLogin}"
                               for="lastLogin"/>

                <p:inputText id="lastLogin"
                             style="width: 100%"               
                             value="#{userController.selected.lastLogin}"
                             disabled="true">

                    <f:convertDateTime 
                        locale="#{localizationUtil.selected}" 
                        type="both"
                        pattern="#{localizationUtil.dateTimeFormatMediumPattern}" 
                        timeZone="#{localizationUtil.defaultTimeZone}"/>      

                </p:inputText>         

            </h:panelGrid>    

        </h:panelGrid>

    </p:dialog>   

    <p:dialog header="#{bundle.Password}"
              widgetVar="generatePasswordDialog" 
              resizable="false" 
              modal="true" 
              showEffect="fade"
              hideEffect="fade" 
              draggable="false"
              style="margin-left: auto; margin-right: auto">

        <h:panelGrid columns="1"
                     columnClasses="columnWidth100"
                     rowClasses="rowAlign"
                     width="90%"
                     style="padding-left: 8%">

            <p:inputText id="generatedPassword"
                         style="text-align: center; width: 100%; margin-bottom: 2%" 
                         value="#{userController.generatedPassword}"
                         readonly="true"/>

            <p:inputTextarea 
                id="userInfo" 
                style="width: 100%; margin-bottom: 2%" 
                value="#{bundle.GeneratedPasswordNote}"
                readonly="true"/>

        </h:panelGrid>

    </p:dialog>  

</html>